package cn.bossfriday.im.common.db;

import cn.bossfriday.common.exception.ServiceRuntimeException;
import cn.bossfriday.im.common.db.entity.AppInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.sql.SQLException;

/**
 * AppInfoDao
 *
 * @author chenx
 */
@Slf4j
@Service
public class AppInfoDao {

    private static final String SQL_GET_BY_ID = "SELECT * FROM app_info WHERE appId = ?";

    /**
     * getById
     *
     * @param appId
     * @return
     * @throws SQLException
     */
    public AppInfo getById(long appId) {
        try {
            return DbUtilExecutor.queryObject(SQL_GET_BY_ID, AppInfo.class, appId);
        } catch (Exception ex) {
            log.error("AppInfoDao.getById() error!", ex);
            throw new ServiceRuntimeException("AppInfoDao.getById() error!");
        }
    }
}
